package com.reading.common.constant;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.ArrayList;
import java.util.List;

/**
 * @author guwenqi_1995@163.com
 * @date 2019/7/9 9:06 AM
 **/
@Getter
@AllArgsConstructor
public enum BookType {

    XUAN_HUAN(1, "玄幻"),
    QI_HUAN(2, "奇幻"),
    WU_XIA(3, "武侠"),
    XIAN_XIA(4, "仙侠"),
    DU_SHI(5, "都市"),
    XIAN_SHI(6, "现实"),
    JUN_SHI(7, "军事"),
    LI_SHI(8, "历史"),
    YOU_XI(9, "游戏"),
    TI_YU(10, "体育"),
    KE_HUAN(11, "科幻"),
    LING_YI(12, "灵异"),
    QING_XIAO_SHUO(13, "轻小说"),
    DUAN_PIAN(14, "短篇"),
    XIU_ZHEN(15, "修真"),

    OTHER(0, "其他")
    ;

    private Integer code;

    private String descr;

    public static List<BookType> getAllBookType() {
        List<BookType> types = new ArrayList<>();
        for (BookType t : BookType.values()) {
            types.add(t);
        }
        return types;
    }

    public static Integer getTypeCode(String type) {
        for (BookType t : BookType.values()) {
            if (t.getDescr().equals(type)) {
                return t.getCode();
            }
        }
        return OTHER.getCode();
    }

}
